package com.ruoyi.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ParkingLane;
import com.ruoyi.service.IParkingLaneService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车道信息Controller
 * 
 * @author dongdong
 * @date 2025-08-30
 */
@RestController
@RequestMapping("/parking/parkingLane")
public class ParkingLaneController extends BaseController
{
    @Autowired
    private IParkingLaneService parkingLaneService;

    /**
     * 查询车道信息列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingLane parkingLane)
    {
        startPage();
        List<ParkingLane> list = parkingLaneService.selectParkingLaneList(parkingLane);
        return getDataTable(list);
    }

    /**
     * 导出车道信息列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:export')")
    @Log(title = "车道信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingLane parkingLane)
    {
        List<ParkingLane> list = parkingLaneService.selectParkingLaneList(parkingLane);
        ExcelUtil<ParkingLane> util = new ExcelUtil<ParkingLane>(ParkingLane.class);
        util.exportExcel(response, list, "车道信息数据");
    }

    /**
     * 获取车道信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkingLaneService.selectParkingLaneById(id));
    }

    /**
     * 新增车道信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:add')")
    @Log(title = "车道信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingLane parkingLane)
    {
        return toAjax(parkingLaneService.insertParkingLane(parkingLane));
    }

    /**
     * 修改车道信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:edit')")
    @Log(title = "车道信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingLane parkingLane)
    {
        return toAjax(parkingLaneService.updateParkingLane(parkingLane));
    }

    /**
     * 删除车道信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingLane:remove')")
    @Log(title = "车道信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkingLaneService.deleteParkingLaneByIds(ids));
    }

    @GetMapping("/selectList")
    public AjaxResult selectList() {
        return success(parkingLaneService.selectList());
    }

    @PostMapping("/getInSideCode")
    public void getInSideCode(ParkingLane parkingLane, HttpServletResponse response) throws Exception{
        parkingLaneService.getInSideCode(parkingLane, response);
    }
    @PostMapping("/getInOutCode")
    public void getInOutCode(ParkingLane parkingLane, HttpServletResponse response) throws Exception{
        parkingLaneService.getInOutCode(parkingLane, response);
    }
}
